Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix occasional WebView2 Crash when restoring minimized app (0x80070057) #6667

Merged
merged 3 commits into from
Feb 3, 2022

Conversation

DmitriyKomin
Copy link
Contributor

If an app is minimized while WebView2 has focus, and is then restored, it occasionally crashes with 0x80070057/ERROR_INVALID_PARAMETER. In my local repro, i observe this on ~1 out of 20 tries. In such cases the Windows restore operation is initiated but for some reason not completed; the app remains minimized. Nonetheless Xaml internal focus handling proceeds to restore focus to WebVIew2, which in turn calls CoreWebView2Controller::MoveFocus to restore web element focus. The latter call fails in Win32 ::SetFocus() API w/ ERROR_INVALID_PARAMETER; this is expected since the target HWND remained minimized.

The fix is to ignore HR 0x80070057 in this situation. Since the app remained minimized in the repro case, there is no observable effect and no additional state cleanup is required. The next attempt to restore the app should restore focus correctly.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Feb 2, 2022
@DmitriyKomin DmitriyKomin self-assigned this Feb 2, 2022
@DmitriyKomin DmitriyKomin linked an issue Feb 2, 2022 that may be closed by this pull request
@krschau krschau changed the title Fix occasional WebVIew2 Crash when restoring minimized app (0x80070057) Fix occasional WebView2 Crash when restoring minimized app (0x80070057) Feb 2, 2022
dev/WebView2/WebView2.cpp Outdated Show resolved Hide resolved
dev/WebView2/WebView2.cpp Show resolved Hide resolved
@krschau krschau self-requested a review February 2, 2022 19:53
@DmitriyKomin
Copy link
Contributor Author

DmitriyKomin commented Feb 2, 2022

/azp run


In reply to: 1028341535

@azure-pipelines
Copy link

azure-pipelines bot commented Feb 2, 2022

Azure Pipelines successfully started running 1 pipeline(s).

In reply to: 1028341710

@azure-pipelines
Copy link

Command 'run

In' is not supported by Azure Pipelines.



Supported commands

  • help:
    • Get descriptions, examples and documentation about supported commands
    • Example: help "command_name"
  • list:
    • List all pipelines for this repository using a comment.
    • Example: "list"
  • run:
    • Run all pipelines or specific pipelines for this repository using a comment. Use this command by itself to trigger all related pipelines, or specify specific pipelines to run.
    • Example: "run" or "run pipeline_name, pipeline_name, pipeline_name"
  • where:
    • Report back the Azure DevOps orgs that are related to this repository and org
    • Example: "where"

See additional documentation.

@DmitriyKomin DmitriyKomin merged commit f2797be into main Feb 3, 2022
@DmitriyKomin DmitriyKomin deleted the user/dkomin/wv2_minimize_crash branch February 3, 2022 16:24
@StephenLPeters StephenLPeters added area-WebView team-Rendering Issue for the Rendering team and removed needs-triage Issue needs to be triaged by the area owners labels Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-WebView team-Rendering Issue for the Rendering team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebView2: UWP App crashes when minimizing maximizing or resizing.
3 participants